<div class="container" id="ajax_content">
    <?php
        include 'header2.php';
    ?>
    <div class="content">
    	<div class="headcontent">
            <span class="randomtext" style="margin-left:50px">Hi, 
            <?php
                global $session;
                $user_id = $session->get('userid');
                $sql="SELECT fullname FROM user WHERE iduser='$user_id'";
		$result=mysql_query($sql);
		while($res = mysql_fetch_array($result)) {
                    $nama = $res['fullname'];
		}
		echo $nama;
            ?>
            </span>
            <span class="randomtext" style="padding-left:900px">PROFILE</span>
        	<hr/>
        </div>
    	<div class="leftcontent" style="width:250px; border-right-style: groove">
            <div style="margin-left: 40px">
                <div class="fotoitem">
                    <img src="<?php echo $pimg;?>" alt="profpic" height="200" width="150" />
                </div>
            </div>
            <div class="clearboth"></div>
            <div>
                <div class="randomtext" style="margin-bottom: 10px; margin-top: 15px">Personal Information</div>
                <div class="item2">
                	<label>Full Name :</label><br/>
                        <label style="text-align:left"><?php echo $user;?></label>
                </div>
                <div class="item2">
                	<label>Birth Date :</label><br/>
                        <label style="text-align:left"><?php echo $pbirthday;?></label>
                </div>
                <div class="item2">
                	<label>E-mail :</label><br/>
                        <label style="text-align:left"><?php echo $pemail;?></label>
                </div>
                <div class="item2">
                	<label>Gender :</label><br/>
                        <label style="text-align:left"><?php if ($pgender == 'P') {echo "Pria";} else {echo "Wanita";};?></label>
                </div>
                <div class="item2">
                	<label>Location :</label><br/>
                        <label style="text-align:left"><?php echo $plocation;?></label>
                </div>
                
            </div>
        </div>
<!--Tampilan Wall-->
        <?php
            global $session;

            $query = "SELECT * FROM wall WHERE iduser='$index'";
            $result = mysql_query($query);
            $res = mysql_fetch_array($result);
            $idwall = $res['idwall'];
            echo $idwall;
        ?>
        <div class="leftcontent" style="width:730px; border-right-style: groove">
            <form action="<?php echo BASE_PATH;?>pother/postwall/<?php echo $idwall;?>" method="post">
                <div>
                    <div class="clearboth"></div>
                </div>
                <div class="wallpost">
                    <div class="post">
                        <textarea rows="2" cols="72" name="postwall"></textarea>
                    </div>
                    <div>
                        <button type="submit">Post</button>
                    </div>
                </div>
            </form>
                <?php
                    $query2 = "SELECT * FROM post_wall WHERE idwall='$idwall'";
                    $result2 = mysql_query($query2);
                    while ($res2 = mysql_fetch_array($result2)) {
                        $query4 = "SELECT * FROM user WHERE iduser='$res2[id_writer]'";
                        $result4 = mysql_query($query4);
                        $res4 = mysql_fetch_array($result4);
                        echo '<div>
                                <div class="wallpost">
                                    <div class="post">
                                        <div class="postitem" style="width: 65px">
                                            <div class="fotoitem">
                                                <img src="images/pudy.jpg" alt="pudy cantik" height="50" width="50" />                            </div>
                                            </div>
                                            <div class="postitem" style="width: 450px">
                                                <label>'.$res4['fullname'].'</label><br/>
                                                <label>'.$res2['isi'].'</label><br/>
                                            </div>
                                            <div class="postitem">
                                                <label>Delete</label>
                                            </div>
                                            <div class="clearboth"></div>
                                        </div>';
                        $query3 = "SELECT * FROM komen_wall WHERE idpost='$res2[idpost]'";
                        $result3 = mysql_query($query3);
                        while ($res3 = mysql_fetch_array($result3)) {
                            $query6 = "SELECT * FROM user WHERE iduser='$res3[id_writer]'";
                            $result6 = mysql_query($query6);
                            $res6 = mysql_fetch_array($result6);
                            echo '<div class="post">
                                    <div class="postitem" style="width: 65px">
                                        <div class="fotoitem">
                                            <img src="images/pudy.jpg" alt="pudy cantik" height="40" width="40" />                            </div>
                                        </div>
                                    <div class="postitem" style="width: 450px">
                                        <label>'.$res6['fullname'].'</label><br/>
                                        <label>'.$res3['isi'].'</label><br/>
                                    </div>
                                    <div class="postitem">
                                        <label>Delete</label>
                                    </div>
                                    <div class="clearboth"></div>
                                  </div>';
                        }
                        $idpost = $res2['idpost'];
                        echo '<div class="post">
                                <form action="'.BASE_PATH.'pother/komenwall/'.$idpost.'" method="post">
                                <div class="post">
                                    <textarea rows="2" cols="72" name="post"></textarea>
                                </div>
                                <div>
                                    <button type="submit">Post</button>
                                </div>
                                </form>
                              </div>
                            </div>
                        </div>';
                    }
                ?>
    <!--            <div>
                    <div class="wallpost">
                        <div class="post">
                            <div class="postitem" style="width: 65px">
                                <div class="fotoitem">
                                    <img src="images/pudy.jpg" alt="pudy cantik" height="50" width="50" />                            </div>
                          </div>
                            <div class="postitem" style="width: 450px">
                                <label>Pudy Prima</label><br/>
                                <label>Hari ini menyenangkan</label><br/>
                                <label>19 Maret 2011</label>
                            </div>
                            <div class="postitem">
                                <label>Delete</label>
                            </div>
                            <div class="clearboth"></div>
                        </div>
                        <div class="post">
                            <div class="postitem" style="width: 65px">
                                <div class="fotoitem">
                                    <img src="images/pudy.jpg" alt="pudy cantik" height="40" width="40" />                            </div>
                          </div>
                            <div class="postitem" style="width: 450px">
                                <label>Pudy Prima</label><br/>
                                <label>Iya menyenangkan, labil ngomenin post sendiri</label><br/>
                                <label>19 Maret 2011</label>
                            </div>
                            <div class="postitem">
                                <label>Delete</label>
                            </div>
                            <div class="clearboth"></div>
                        </div>
                        <div class="post">
                            <div class="post">
                                <textarea rows="2" cols="72" name="post"></textarea>
                            </div>
                            <div>
                                <button type="submit">Post</button>
                            </div>
                        </div>
                    </div>
                    <div class="wallpost">
                        <div class="post">
                            <div class="postitem" style="width: 65px">
                                <div class="fotoitem">
                                    <img src="images/pudy.jpg" alt="pudy cantik" height="50" width="50" />                            </div>
                          </div>
                            <div class="postitem" style="width: 450px">
                                <label>Pudy Prima</label><br/>
                                <label>Hari ini menyebalkan X(</label><br/>
                                <label>18 Maret 2011</label>
                            </div>
                            <div class="postitem">
                                <label>Delete</label>
                            </div>
                            <div class="clearboth"></div>
                        </div>
                        <div class="post">
                            <div class="post">
                                <textarea rows="2" cols="72" name="post"></textarea>
                            </div>
                            <div>
                                <button type="submit">Post</button>
                            </div>
                        </div>
                    </div>
                </div>-->
            
        </div>
<!--Selesai Tampilan Wall-->
        <div class="leftcontent" style="width:250px; padding-left: 20px">
            <div class="right1" style="margin-bottom: 20px; margin-top: 20px">
                <div class="randomtext">Following</div>
                 <?php 
                        global $session;

                        $sql_follower = "SELECT idfollowed FROM follow_user WHERE iduser='$index'";
                        $result_tag = mysql_query($sql_follower);
                        while($res_tag = mysql_fetch_array($result_tag)){
                            $nama_tag = $res_tag['idfollowed'];
                            $sql_name = "SELECT fullname FROM user WHERE iduser='$nama_tag'";
                            $result_name = mysql_query($sql_name);
                            while($res = mysql_fetch_array($result_name)) {
                        $pic = $res['fullname'];
                    }
                ?>
                		<a href="<?php echo BASE_PATH;?>pother/index/<?php echo $nama_tag?>">
                		<div class="fotoitem">
                        	<div class="randomtext"> <?php echo $pic?> </div>
                        </div>
                        </a>
                <?php
						}
				?>
            </div>
            <div class="right1" style="margin-bottom: 25px">
                <div class="randomtext">Follower</div>
                <div>
                
                <?php 
						global $session;
						
						$sql_follower = "SELECT iduser FROM follow_user WHERE idfollowed='$index'";
						$result_tag = mysql_query($sql_follower);
						while($res_tag = mysql_fetch_array($result_tag)){
							$nama_tag = $res_tag['iduser'];
							$sql_name = "SELECT fullname FROM user WHERE iduser='$nama_tag'";
							$result_name = mysql_query($sql_name);
							while($res = mysql_fetch_array($result_name)) {
                				$pic = $res['fullname'];
            				}
				?>
                		<a href="<?php echo BASE_PATH;?>pother/index/<?php echo $nama_tag?>">
                		<div class="fotoitem">
                        	<div class="randomtext"> <?php echo $pic?> </div>
                        </div>
                        </a>
                <?php
						}
				?>
              </div>
            </div>
            <div class="clearboth"></div>
            <div class="right1" style="padding-bottom: 15px; border-bottom-style: groove">
            	<div>
                <a href="<?php echo BASE_PATH . "pother/follow/" . $index?>"
                    <button type="button"  name="followbtn">FOLLOW!</button>
                </a>
                </div>
            </div>
            <div class="right1" style="margin-top: 35px">
                <div class="randomtext">Photos</div>
                <div>
                    <?php 
						global $session;
						
						$sql = "SELECT deskripsi,idfoto FROM foto WHERE iduser='$index'";
						$result_tag = mysql_query($sql);
						while($res_tag = mysql_fetch_array($result_tag)){
							$id_foto = $res_tag['idfoto'];
							$deskripsi = $res_tag['deskripsi'];
					?>
                		<a href="<?php echo BASE_PATH;?>pdetail/index/<?php echo $id_foto?>">
                		<div class="fotoitem">
                        	<div class="randomtext"> <?php echo $deskripsi?> </div>
                        </div>
                        </a>
                <?php
						}
				?>
              </div>
            </div>
            <div class="clearboth"></div>
        </div>
        <div class="clearboth"></div>
    </div>
    <div class="footer"></div>
</div>
</body>
</html>
